﻿//https://leetcode.cn/problems/group-anagrams/

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) \
    {
        unordered_map <string, vector<string>> hash;
        for (auto& s : strs)
        {
            string temp = s;
            sort(s.begin(), s.end());
            hash[s].push_back(temp);  //把排完序后相同的字符串放入同一个数组
        }
        vector<vector<string>> ret;
        for (auto& [x, y] : hash)
        {
            ret.push_back(y);
        }
        return ret;

    }
};